function compare(a, b) {
  let start = parseInt(a.slice(1));
  let end = parseInt(b.slice(1));
  let num = start - end;
  if (num === 0) {
    return a.charCodeAt(0) - b.charCodeAt(0);
  }
  return num;
}

// 快排思想
function sort(arr, l = 0, r = arr.length - 1) {
  if (l >= r) return;
  let basic = l;
  while (l < r) {
    while (l < r && compare(arr[r], arr[basic]) >= 0) {
      r--;
    }
    while (l < r && compare(arr[basic], arr[l]) >= 0) {
      l++;
    }
    if (l !== r) {
      [arr[l], arr[r]] = [arr[r], arr[l]];
    }
  }
  [arr[l], arr[basic]] = [arr[basic], arr[l]];
  sort(arr, basic, l - 1);
  sort(arr, r + 1, arr.length - 1);
}

// test...
let str = ["B3", "D2", "F1", "A9", "D12", "A2", "C1", "Z0", "B1"];
sort(str);
console.log(str);
